<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>绿植租赁</title>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="//cdn.bootcss.com/weui/0.4.3/style/weui.min.css">
		<link rel="stylesheet" href="//cdn.bootcss.com/jquery-weui/0.8.3/css/jquery-weui.min.css">
		<link rel="stylesheet" href="../css/index.css" />
	</head>
	<body id="house">
		<header>
			<div id="swiper-container1" class="swiper-container" data-space-between='10' data-pagination='.swiper-pagination' data-autoplay="1000">
				<div class="swiper-wrapper" id="carousellist">
					<!--<div class="swiper-slide"><img src="../img/csc.png" /></div>
					<div class="swiper-slide"><img src="../img/csc.png" /></div>
					<div class="swiper-slide"><img src="../img/csc.png" /></div>
					<div class="swiper-slide"><img src="../img/csc.png" /></div>-->
				</div>
				<div class="swiper-pagination"></div>
			</div>
		</header>
		<div class="top_xx">
			<section>
				<b>万象资讯</b>
					<div id="swiper-container2" class="swiper-container1">
						<div class="swiper-wrapper in_list" id="newslist">
				        	<!--<div class="swiper-slide"><p>万象物业上线啦！</p></div>
				        	<div class="swiper-slide"><p>全场八折！</p></div>
				        	<div class="swiper-slide"><p>走过路过不要错过</p></div>-->
						</div>
					</div>
				<a href="fournewslist.html?type=4">
				<strong>
					|&nbsp;&nbsp;更多
				</strong>
				</a>
			</section>
		</div>
		<div class="main">
			<ul>
				<!--<a href="marketdetails.html">
				<li>
					<img src="../img/cc.png"/>
					<h1>老农自家种植大白菜</h1>
					<span><b>5</b>元/斤</span>
					<div class="clear"></div>
				</li>
				</a>
				<a href="marketdetails.html">
				<li>
					<img src="../img/cc.png"/>
					<h1>老农自家种植大白菜</h1>
					<span><b>10</b>元/斤</span>
					<div class="clear"></div>
				</li>
				</a>
				<a href="marketdetails.html">
				<li>
					<img src="../img/cc.png"/>
					<h1>老农自家种植大白菜</h1>
					<span><b>20</b>元/斤</span>
					<div class="clear"></div>
				</li>
				</a>
				<a href="marketdetails.html">
				<li>
					<img src="../img/cc.png"/>
					<h1>老农自家种植大白菜</h1>
					<span><b>250</b>元/斤</span>
					<div class="clear"></div>
				</li>
				</a>-->
			</ul>
		</div>
		
		<script src="//cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
		<script src="//cdn.bootcss.com/jquery-weui/0.8.3/js/jquery-weui.min.js"></script>
		<script src="//cdn.bootcss.com/jquery-weui/0.8.3/js/swiper.min.js"></script>
		<script type="text/javascript" src="../js/basic.js" ></script>
		<script type="text/javascript">
			function lunbo1() {
				var mySwiper = new Swiper('#swiper-container1', {
					autoplay: 3000,
					pagination: '.swiper-pagination',
					paginationClickable: true,
				});
			}
			function lunbo2() {
				var mySwiper = new Swiper('#swiper-container2', {
			        paginationClickable: true,
			        direction: 'vertical',
			        autoplay : 3000,
			        loop: true
				});
			}
			var ip_addr = getUrl();
			var pageNo = 1;
			var pageSize = 4;
			var loading = false;
			$(document).ready(function() {
				indexCarousellist();
				newslist();
				servelist()
				$("body").infinite().on("infinite", function() {
					 if(loading) return;
					  loading = true;
					  setTimeout(function() {
					    pageNo++; 
					    servelist()
					    loading = false;
					  }, 800); 
				});
			});
			//物业服务轮播图接口
			function indexCarousellist() {
				$.ajax({
					type: 'post',
					dataType: "json",
					url: ip_addr + 'indexCarousel/list',
					data: {
						type: 4
					},
					success: function(data) {
						var result = data.rows;
						var innerHTML = '';
						if(data.code == 0) {
							for(var i = 0; i < result.length; i++) {
								innerHTML +='<div class="swiper-slide">';
								if(result[i].relation == 1){
									innerHTML +='<a href="presslistdetails.html?id='+result[i].jumpId+'">';
								}else if(result[i].relation == 2){
									innerHTML +='<a href="plantsdetails.html?id='+result[i].jumpId+'">';
								}else{
									innerHTML +='<a href="javascript:;">';
								}
								
								innerHTML +='<img src="'+result[i].img.replace('../',"")+'" />';
								innerHTML +='</a>';
								innerHTML +='</div>';
							}
							$("#carousellist").append(innerHTML);
							lunbo1();
						} else {
							alert(data.msg);
						}
					}
				});
			}
			//首页新闻滚动前5条
			function newslist() {
				$.ajax({
					type: 'post',
					dataType: "json",
					url: ip_addr + 'news/indexList',
					data: {
						type: 4
					},
					success: function(data) {
						var result = data.rows;
						var innerHTML = '';
						if(data.code == 0) {
							for(var i = 0; i < result.length; i++) {
								innerHTML +='<div class="swiper-slide" style="overflow: hidden;">';
								innerHTML +='<a href="presslistdetails.html?id='+result[i].id+'">';
								innerHTML +='<p>'+result[i].title+'</p>';
								innerHTML +='</a>';
								innerHTML +='</div>';
							}
							$("#newslist").append(innerHTML);
							lunbo2();
						} else {
							
						}
					}
				});
			}
			//家政服务列表
			function servelist() {
				$.ajax({
					type: 'post',
					dataType: "json",
					url: ip_addr + 'serve/list ',
					data: {
						type: 4,
						pageNo:pageNo,
						pageSize:pageSize
					},
					success: function(data) {
						var result = data.rows;
						var innerHTML = '';
						if(data.total <= pageNo*pageSize){
							loading = true;
							$(".loading").hide();
						}else{
							loading = false;
						}
						if(data.total < 4){
							$(".loading").hide();
						}
						if(data.code == 0) {
							for(var i = 0; i < result.length; i++) {
								innerHTML +='<a href="plantsdetails.html?id='+result[i].id+'">';
								innerHTML +='<li>';
								innerHTML +='<img src="'+result[i].img.replace('../',"")+'"/>';
								innerHTML +='<h1>'+result[i].name+'</h1>';
								innerHTML +='<span><b>'+(result[i].price/100)+'</b>元/'+result[i].punit+'</span>';
								innerHTML +='<div class="clear"></div>';
								innerHTML +='</li>';
								innerHTML +='</a>';
							}
							$(".main ul").append(innerHTML);
						} else {
							alert(data.msg);
						}
					}
				});
			}
		</script>
	</body>
</html>
